//
//  CWCBaseViewController.m
//  ChuanNews
//
//  Created by dllo on 16/4/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CWCBaseViewController.h"
#import "JXLDayAndNightMode.h"
#import "BaseHeader.h"
@interface CWCBaseViewController ()

@end

@implementation CWCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    UIColor *color = [UIColor redColor];
//    NSDictionary *dic = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
//    self.navigationController.navigationBar.
//    titleTextAttributes = dic;
//    
//    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.navigationController.automaticallyAdjustsScrollViewInsets = NO;
    [self.view jxl_setDayMode:^(UIView *view) {
        
        // 设置日间模式状态
        view.backgroundColor = [UIColor whiteColor]; // view为当前设置的视图
        
    } nightMode:^(UIView *view) {
        
        // 设置夜间模式状态
        view.backgroundColor = [UIColor blackColor]; // view为当前设置的视图
        
    }];
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:  180 / 255.0 green:240 / 255.0 blue: 83 / 255.0 alpha:1];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view jxl_setDayMode:^(UIView *view) {
        
        // 设置日间模式状态
        view.backgroundColor = [UIColor whiteColor]; // view为当前设置的视图
        
    } nightMode:^(UIView *view) {
        
        // 设置夜间模式状态
        view.backgroundColor = [UIColor blackColor]; // view为当前设置的视图
        
    }];
    
    [self.navigationController.navigationBar jxl_setDayMode:^(UIView *view) {
        UINavigationBar *bar = (UINavigationBar *)view;
        // 改变状态栏前景色为黑色
        bar.barStyle = UIBarStyleDefault;
        bar.barTintColor = AppColor;
    } nightMode:^(UIView *view) {
        
        UINavigationBar *bar = (UINavigationBar *)view;
        // 改变状态栏前景色为白色
        bar.barStyle = UIBarStyleBlack;
        bar.barTintColor = [UIColor blackColor];
    }];
    
    [self.tabBarController.tabBar jxl_setDayMode:^(UIView *view) {
        UITabBar *bar = (UITabBar *)view;
        bar.barStyle = UIBarStyleDefault;
        bar.barTintColor = AppColor;
    } nightMode:^(UIView *view) {
        UITabBar *bar = (UITabBar *)view;
        bar.barStyle = UIBarStyleBlack;
        bar.barTintColor = [UIColor blackColor];
    }];

    
//    //监听中心,监听后面发来的信息
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"CWC" object:nil];
//    
//    //从night中取出储存的字符串(yes,day)
//    //本地存储
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    //key存储
//    NSString *passWord = [user objectForKey:@"night"];
//    
//    
//    //判断信息
//    if ([passWord isEqualToString:@"yes"]) {
//        self.view.backgroundColor = [UIColor blackColor];
//        
//        [self.navigationController.navigationBar setBarTintColor:[UIColor blackColor]];
//        self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
//        /* 设置navigation上字体的颜色 */
//        UIColor *color = [UIColor whiteColor];
//        NSDictionary *dic = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
//        self.navigationController.navigationBar.titleTextAttributes = dic;
//        self.view.tintColor = [UIColor whiteColor];
//        
//        
//        
//    } else {
//        //背景
//        self.view.backgroundColor = [UIColor whiteColor];
//        
//        //navi
//        [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:  180 / 255.0 green:240 / 255.0 blue: 83 / 255.0 alpha:1]];
//        self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:  180 / 255.0 green:240 / 255.0 blue: 83 / 255.0 alpha:1];
//        /* 设置navigation上字体的颜色 */
//        UIColor *color = [UIColor redColor];
//        NSDictionary *dic = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
//        self.navigationController.navigationBar.titleTextAttributes = dic;
//        
//    }
//    
}
//
//
////监听中心监听到后面发出的信息,就调用此方法
//- (void)changeColor:(NSNotification *)notification
//{
//    //改变背景颜色
//    self.view.backgroundColor = [UIColor blackColor];
//    [self.navigationController.navigationBar setBarTintColor:[UIColor blackColor]];
//    /* 设置navigation上字体的颜色 */
//    UIColor *color = [UIColor whiteColor];
//    NSDictionary *dic = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
//    self.navigationController.navigationBar.titleTextAttributes = dic;
//    self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
//    self.view.tintColor = [UIColor whiteColor];
//    
//    //找到字符
//    NSString *passWord = [notification object];
//    //判断是yes还是no,yes的话改变背景颜色
//    if ([passWord isEqualToString:@"no"]) {
//        self.view.backgroundColor = [UIColor whiteColor];
//        [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:  180 / 255.0 green:240 / 255.0 blue: 83 / 255.0 alpha:1]];
//        self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:  180 / 255.0 green:240 / 255.0 blue: 83 / 255.0 alpha:1];
//        /* 设置navigation上字体的颜色 */
//        UIColor *color = [UIColor redColor];
//        NSDictionary *dic = [NSDictionary dictionaryWithObject:color forKey:UITextAttributeTextColor];
//        self.navigationController.navigationBar.titleTextAttributes = dic;
//       
//    }
//    //消息中心发出消息NSUserDefaults将object中的字符串存入night中
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    [user setObject:passWord forKey:@"night"];
//    
//    
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
